package cn.tedu.boot51.controller;

import cn.tedu.boot51.mapper.EmpMapper;
import cn.tedu.boot51.vo.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class EmpController {
    @Autowired(required = false)
    EmpMapper mapper;

    @RequestMapping("/insert")
    public void insert(Emp emp){
        mapper.insert(emp);
    }
    @RequestMapping("/select")
    public List<Emp> select(){
        //SpringMVC框架会自动将返回的对象或集合装成JSON格式的字符串  JSON:一种轻量级数据交换的格式
        //然后再将字符串装成二进制数据 网络传输给客户端
        return mapper.select();
    }
    @RequestMapping("/select2")
    public List<Emp> select2(){
        return mapper.select2();
    }
    @RequestMapping("/delete")
    public void delete(int id){
        mapper.delete(id);
    }
    @RequestMapping("/selectById")
    public Emp selectById(int id){
        return mapper.selectById(id);
    }
    @RequestMapping("/update")
    public void update(Emp emp){
        mapper.update(emp);
    }
}
